<?php
namespace app\admin\controller;
use app\admin\code\BaseCode;
use app\admin\logic\UserLogic;
use app\admin\model\UserModel;
use app\admin\util\Page;
use app\admin\util\Response;
use app\admin\validate\UserValidate;

class User extends Base
{
    public function index(){
        if($this->request->isAjax()){
            $model = new UserModel();
            $list = $model->selectData([]);
            $size = input('limit',10,'intval');
            $page = input('page',1,'intval');
            Response::json(BaseCode::SUCCESS,'',Page::return_page_data($list,$size,$page));
        }else{
            return view();
        }
    }
    public function update_status(){
        $param = [];
        $param['id'] = input('id',0,'intval');
        $param['is_use'] = input('is_use',0,'intval');
        $logic = new UserLogic($param);
        if($logic->update_status(new UserValidate(new UserModel()))){
            Response::json(BaseCode::SUCCESS);
        }else{
            Response::json($logic->err['code'],$logic->err['msg']);
        }
    }


}